<template>
  <div class="execution">
    <basic-container>
      <div style="margin-top: 10px">
        <el-table
          :data="list"
          border
          :header-cell-style="{ color: '#4D4D4D', background: '#fafafa' }"
        >
          <el-table-column
            label="名称"
            align="center"
            prop="name"
          ></el-table-column>

          <el-table-column
            label="免减金额"
            align="center"
            prop="minusMoney"
          ></el-table-column>

          <el-table-column
            label="条件金额"
            align="center"
            prop="conditMoney"
          ></el-table-column>

          <el-table-column
            label="数量"
            align="center"
            prop="quantity"
          ></el-table-column>

          <el-table-column label="时间范围" align="center">
            <template slot-scope="scope">
              {{ scope.row.beginTime }}- {{ scope.row.endTime }}
            </template>
          </el-table-column>

          <el-table-column
            label="使用条件"
            align="center"
            prop="type"
          ></el-table-column>

          <el-table-column
            label="领取数量"
            align="center"
            prop="receive"
          ></el-table-column>

          <el-table-column label="状态" align="center" prop="status">
            <template slot-scope="scope">
              {{ scope.row.status | statusFilters }}
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="pagination-container">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          layout="total, sizes,prev, pager, next,jumper"
          :page-size="listQuery.size"
          :page-sizes="[5, 10, 15]"
          :current-page.sync="listQuery.current"
          :total="total"
        >
        </el-pagination>
      </div>
    </basic-container>
  </div>
</template>
    
<script>
import "@/styles/index.scss";
import { couponPage } from "@/api/marke/index";

export default {
  data() {
    return {
      listQuery: {
        current: 1,
        size: 10,
      },
      list: [],
      total: 0,
    };
  },
  filters: {
    statusFilters(value) {
      if (value === 1) {
        return "未支付";
      } else if (value === 2) {
        return "已支付";
      }
    },
  },
  created() {
    this.getList();
  },
  methods: {
    handleSizeChange(val) {
      this.listQuery.size = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.listQuery.current = val;
      this.getList();
    },
    getList() {
      couponPage(this.listQuery).then((res) => {
        this.list = res.data.data.records;
        this.total = res.data.data.total;
      });
    },
  },
};
</script>
    
    <style>
</style>